<template>
    <view class="content">
        <van-nav-bar left-arrow @click-left="onClickLeft" :border="false"  class="fixed_top" id="navBar"> </van-nav-bar>
        <view class="top">
            <view class="topText">长按识别二维码</view>
            <view class="topText">关注17乐生活官方账号</view>
            <view style="padding: 36rpx 0rpx;width: 32rpx; height: 18rpx; line-height: 18rpx;"> <img src="https://17lelife-bucket.oss-cn-beijing.aliyuncs.com/WeChat-App-Picture/blackTriangleIcon.png" alt="" style="width: 32rpx; height: 18rpx;"></view>
            <view class="image">
                <image :src="imageUrl" alt="" style="" mode="widthFix" show-menu-by-longpress></image>
            </view>
            <!-- <view class="ourLogo">
                <img src="https://17lelife-bucket.oss-cn-beijing.aliyuncs.com/WeChat-App-Picture/ourLogo1227.png" alt=""  style="" mode="widthFix">
            </view> -->
        </view>
    </view>
</template>
<script>
export default {
  data () {
      return {
        imageUrl:'https://17lelife-bucket.oss-cn-beijing.aliyuncs.com/WeChat-App-Picture/QRcode1227.png'  
      }
  },
  onReady () {
  // 清除缓存
  // uni.clearStorage()
  },
  methods: {
      phoneLogin () {
          if (!this.checked) {
              Toast('请先勾选同意服务协议')
              return false
          }
          uni.navigateTo({
              url: '/pages/login/phoneLogin'
          })
      },
      onClickLeft () {
          uni.navigateBack({
              delta: 1
          })
      },

   
  
      userAgreement () {
          console.log('用户协议')
          uni.navigateTo({
              url: '/pages/login/userAgreement'
          })
      },
      login () {
          if (!this.checked) {
              Toast('请先勾选同意服务协议')
              return false
          }

          if (!this.isSendMsg) {
              Toast('请先点击发送验证码')
              return false
          }

          this.doLogin()
      },
      secrectAgreement () {
          console.log('隐私协议')
          uni.navigateTo({
              url: '/pages/login/secrectAgreement'
          })
      },
   
   
      onChange (e) {
          if (e.target.id !== 'secrectAgreement') {
              this.checked = !this.checked
          }
      },
      previewImage () {
        var current = 'https://profile.csdnimg.cn/4/6/5/2_qq_35713752.png';
        wx.previewImage({
        urls: [current]
        })
    },
      handleLongPress(event) {
          event.stopPropagation(); // 阻止事件冒泡
          // 这里可以调用小程序的识别二维码API，具体API因小程序平台而异
          // 在uni - app中可以使用uni.scanCode等相关API
          wx.showActionSheet({
              itemList: ["识别图中二维码"],
              success: function (res) {
                  if (res.tapIndex === 0) {
                      wx.scanCode({
                        needResult:true,
                        scanType:["qrCode","barCode"],
                        onlyFromCamera: false, // 确保这里设置为false
                          success: (res) => {
                              console.log('识别结果:', res);
                              if (res.result.startsWith('http')) {
                                  // 使用uni.navigateTo或者uni.switchTab等导航方式跳转到对应的网址
                                  uni.navigateTo({
                                      url: res.result
                                  });
                              } else if (res.result.includes('product_id=')) {
                                  // 假设二维码内容包含产品ID，用于查询产品详情
                                  const productId = res.result.split('product_id=')[1];
                                  this.getProductDetails(productId);
                              }
                          }
                      });
                  }
              }
          })

      }
     
  }
}
</script>
<style lang="scss" scoped>
.content {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    // background: url('https://17lelife-bucket.oss-cn-beijing.aliyuncs.com/WeChat-App-Picture/loginBg.png') no-repeat;
    background-size: 100%;

    .fixed_top {
        position: fixed;
        width: 100%;
        z-index: 999;
    }
}
.top{
    padding: 0 24px;
    height: 100vh;
    display:flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    align-items:center;
    padding-top: -40px;
}
.image{
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 0px auto;
    width: 520rpx;
    height: 520rpx;
    img{
        width: 100%;
        height: auto;
    }
}
.topText{
    font-size: 30rpx;
    color: #111111;
    text-align: center;
    margin-top: 14rpx;
}
.ourLogo{
    width: 320rpx;
    // height: 60rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 0px auto;
    img{
        width: 100%;
        height: auto;
    }
}

.t14{
    margin-top: 14px;
}
.t8{
    margin-top: 16rpx;
}
::v-deep .van-nav-bar {
    background-color: transparent !important;
}
::v-deep .van-icon {
    color: #242629 !important;
}
</style>
